﻿using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace IdentityWebApi
{
    public class User:IdentityUser<long>
    {
        public DateTime CreateTime { get; set; }
        public string? NickName { get; set; }
        public long JwtVersion { get; set; }
    }

    public class UserConfig:IEntityTypeConfiguration<User>
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
            builder.ToTable("T_User");
            builder.Property(x => x.CreateTime).HasDefaultValue(DateTime.Now);
            builder.Property(x => x.NickName).HasMaxLength(50);
            builder.Property(x=>x.NormalizedUserName).HasMaxLength(50);
            builder.Property(x=>x.Email).HasMaxLength(50);
            builder.Property(x=>x.NormalizedEmail).HasMaxLength(50);
            builder.Property(x=>x.PhoneNumber).HasMaxLength(50);
        }
    }

    public class Role:IdentityRole<long>
    {
        
    }

    public class RoleConfig : IEntityTypeConfiguration<Role>
    {
        public void Configure(EntityTypeBuilder<Role> builder)
        {
            builder.ToTable("T_Role");
            builder.Property(r => r.Name).HasMaxLength(50);
            builder.Property(r=>r.NormalizedName).HasMaxLength(50);
        }
    }
}
